#进程 processing
import os
import time
from  multiprocessing import Pool

def sonpro(pram):
    start_time = time.time()
    time.sleep(1)
    end_time = time.time()
    print('我是子进程%s 父进程 %s 我操作了任务%d 用时%d秒' % (os.getpid(),os.getppid(), pram,end_time-start_time))




def main():
    print('主进程start Pid=',os.getpid())
    start =time.time()
    #开启子进程
    numbers = 3
    p = Pool(numbers)
    for i in range(10) :
        #p.apply_async(sonpro,(i,))
        p.apply(sonpro,(i,))
    p.close()
    p.join()
    end = time.time()
    print('所有子进程end Pid=',os.getpid(),'总用时', end-start )

if __name__ == '__main__' :
    main()